package com.example.smart_community.mapper;

import com.example.smart_community.po.Houseinfo;
import com.example.smart_community.po.Maintainrequest;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface MaintainrequestMapper {
    @Select("select * from maintainrequest where id=#{id}")
    @Results({
            @Result(property="hId", column="h_id"),
            @Result(
                    property ="houseinfo" ,column ="h_id",
                    javaType= Houseinfo.class,
                    one=@One(select ="com.example.smart_community.mapper.HouseinfoMapper.selectById")
            )
    })
    Maintainrequest selectById(Integer id);
    @Select("select * from  maintainrequest where h_id=#{hId}")
    @Results({
            @Result(property="hId", column="h_id"),
            @Result(
                    property ="houseinfo" ,column ="h_id",
                    javaType= Houseinfo.class,
                    one=@One(select ="com.example.smart_community.mapper.HouseinfoMapper.selectById")
            )
    })
    List<Maintainrequest> selectByHId(Integer hId);
    @Select("select * from maintainrequest where name=#{name} and requesttime=#{requesttime}")
    Maintainrequest selectByNameAndRequesttime(String name,String requesttime);
    @Insert("insert into maintainrequest (name,phone,content,h_id,requesttime) VALUES(#{name},#{phone},#{content},#{hId},#{requesttime})")
    @Results({
            @Result(property="hId", column="h_id")
    })
    int insert1(@Param("name") String name,@Param("phone") String phone,@Param("content")String content,@Param("hId")Integer hId,@Param("requesttime") String requesttime);
    @Insert("insert into maintainrequest (name,phone,content,address,requesttime) VALUES(#{name},#{phone},#{content},#{address},#{requesttime})")
    int insert2(@Param("name") String name,@Param("phone") String  phone,@Param("content")String content,@Param("address")String address,@Param("requesttime") String requesttime);
}
